﻿namespace MagicKey.Interfaces
{
    public interface IAccessManager
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        string EncryptFileSym(string path, string key);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        string DecryptFileSym(string path, string key);

        /// <summary>
        /// </summary>
        /// <param name="publicKey"></param>
        /// <param name="plainFileName"></param>
        string EncryptFileAsym(string publicKey, string plainFileName);

        /// <summary>
        /// </summary>
        /// <param name="privateKey"></param>
        /// <param name="encryptedFileName"></param>
        string DecryptFileAsym(string privateKey, string encryptedFileName);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="plainText"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        string EncryptStringSym(string plainText, string key);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="plainText"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        string DecryptStringSym(string plainText, string key);

        /// <summary>
        ///     Generate a 64 bits sysmetric Key
        /// </summary>
        /// <returns>a generate sysmetric key</returns>
        string GenerateSysmKey();

        /// <summary>
        ///     generate asymetric keys pair
        /// </summary>
        /// <returns>array of public and private key. first key in a array is a public key</returns>
        string[] GenerateAsymKeysPair();

        /// <summary>
        ///     Hash a password with MD5 Algorithm
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        string HashPassword(string password);

        /// <summary>
        ///     Generate a Salt
        /// </summary>
        /// <returns>a salt value</returns>
        string GenerateSalt();

        /// <summary>
        ///     Hash a hashed password and salt with MD5 Algorithm
        /// </summary>
        /// <param name="password"></param>
        /// <param name="salt"></param>
        /// <returns></returns>
        string HashHashedPasswordAndSalt(string password, string salt);

        /// <summary>
        ///     Verifi if a credential a valid
        /// </summary>
        /// <param name="password">username of user</param>
        /// <param name="username">uncryted password of user</param>
        /// <returns>true if credential is valid else false</returns>
        bool VerifyUserPassword(string username, string password);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sInputFilename"></param>
        /// <returns></returns>
        string GetEncryptedFilename(string sInputFilename);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        bool HasAuthorization(int userId, string path);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="userPublicKey"></param>
        /// <param name="userSymetricKey"></param>
        /// <returns></returns>
        string EncryptStringAsym(string userPublicKey, string userSymetricKey);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="userPublicKey"></param>
        /// <param name="userSymetricKey"></param>
        /// <returns></returns>
        string DecryptStringAsym(string userPublicKey, string userSymetricKey);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="recipient"></param>
        /// <param name="file"></param>
        /// <param name="encryptedSymetricKeyOfRecipient"></param>
        /// <param name="encryptedSymetricKeyOfSender"></param>
        /// <returns></returns>
        bool InsertAuthorisationAccess(int sender, int recipient, int file, string encryptedSymetricKeyOfRecipient,
            string encryptedSymetricKeyOfSender);


        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <param name="userId"></param>
        /// <param name="isOwner"></param>
        /// <returns></returns>
        string GetEncryptedSymetricKeyOfFile(string path, int userId, bool isOwner);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="i"></param>
        bool RemoveAuthorization(int i);
    }
}